package study.distributed.transaction.config;

import com.atomikos.icatch.jta.UserTransactionImp;
import com.atomikos.icatch.jta.UserTransactionManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.jta.JtaTransactionManager;

@Configuration
public class XATransactionManagerConfig {

    @Bean
    public PlatformTransactionManager transactionManager() {
        UserTransactionImp userTransactionImp = new UserTransactionImp();
        UserTransactionManager userTransactionManager = new UserTransactionManager();
        userTransactionManager.setForceShutdown(false);
        return new JtaTransactionManager(userTransactionImp,userTransactionManager);
    }
}
